﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<!--作为公共模版分离出去-->
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="admin/images/rookieCs.ico" />
	<link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/layui/2.5.6/css/layui.css" />
	<link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
	<script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script type="text/javascript" src="admin/lib/layui/2.5.6/layui.js"></script>
	<script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
	<script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
	<!--作为公共模版分离出去-->
    <link rel="stylesheet" type="text/css" href="admin/lib/zyUpload/control/css/zyUpload.css" />
    <script>document.write('<script type="text/javascript" src="admin/lib/zyUpload/core/zyFile.js?v='+ Date.now() +'"><\/script>');</script>
    <script>document.write('<script type="text/javascript" src="admin/lib/zyUpload/control/js/zyUpload.js?v='+ Date.now() +'"><\/script>');</script>
	<script type="text/javascript" src="admin/lib/echarts/4.8.0/echarts.min.js"></script>
	<title>新增抖音号</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="medium-video-self">
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en" style="float: none">&gt;</span> 抖音号管理
	<span class="c-gray en" style="float: none">&gt;</span> 新增抖音号
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
	<!--按钮元素-->
	<div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
		<button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
		<button class="easyui-linkbutton" onclick="addMedium()"><i class="Hui-iconfont">&#xe600;</i>新增</button>
		<button class="easyui-linkbutton" onclick="editMedium()"><i class="Hui-iconfont">&#xe6df;</i>修改</button>
		<button class="easyui-linkbutton" onclick="delMedium()"><i class="Hui-iconfont">&#xe6e2;</i>删除</button>
		<button class="easyui-linkbutton" onclick="delegateMedium()"><i class="Hui-iconfont">&#xe62c;</i>转授</button>
	</div>
	<!--表格元素-->
	<div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
	<!--查询条件元素-->
	<form id="searchFormInfo" style="display: none">
        <div class="searchLabel">达人类别：<input id="s_label" name="label"/></div>
        <div class="searchLabel">达人昵称：<input id="s_name" name="name"/></div>
        <div class="searchLabel">星图ID：<input id="s_weChatNo" name="weChatNo"/></div>
		<div class="searchLabel"><input id="s_numberType" name="numberType" /><input id="s_numberStart" name="numberStart" />-<input id="s_numberEnd" name="numberEnd" /></div>
		<div class="searchLabel">公司主体：<input id="s_hostCompany" name="hostCompany"/></div>
	</form>
</div>
<script type="text/javascript">
    //准备函数
    $(function () {
		initSearchForm();
		initGrid();
		getGridHidden("tableInfo");
        query(pageParam);
    });

	//查询条件初始化
	function initSearchForm() {
		$("#s_label").combobox({
			width: 150,
			editable: true,
			valueField: 'labelName',
			textField: 'labelName',
			url: "medium/getMediumLabelList?type=3",
			method: "GET",
			loadFilter: function (data) {
				return data.bizData;
			}
		});
		$("#s_name").textbox({
			width: 150
		});
        $("#s_weChatNo").textbox({
            width: 174
        });
		$("#s_numberType").combobox({
			width: 220,
			panelHeight: "auto",
			valueField: "value",
			textField: "text",
			data: [{value:1, text:"粉丝数量(万)", selected:true}, {value:12, text:"返点比例"}]
		});
		$("#s_numberStart").numberbox({
			width: 108
		});
		$("#s_numberEnd").numberbox({
			width: 108
		});
		$("#s_hostCompany").textbox({
			width: 160
		});
		$("#searchFormInfo").show();
	}

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
            pagination: true,
            singleSelect: false,
            fitColumns: false,
            striped: true,
            fit: true,
            frozenColumns: [[
                {field: "ck", checkbox: "true"},
                {field: "id", title: "编号", width: 60, align: "center", sortable: true},
                {field: "label", title: "达人类别", width: 100, align: "center", sortable: true},
                {field: "name", title: "达人昵称", width: 120, align: "center", sortable: true, formatter: mediumNameFormatter}
            ]],
            columns: [[
                {field: "weChatNo", title: "星图ID", width: 100, align: "center"},
                {field: "fansSheets", title: "粉丝数量(万)", width: 100, align: "center", sortable: true},
                {field: "rebatesRate", title: "返点比例（%）", width: 100, align: "center", sortable: true},
                {field: "hostCompany", title: "公司主体", width: 100, align: "center", sortable: true},
                {field: "hostContact", title: "联系方式", width: 120, align: "center"},
                {field: "createUserName", title: "对接员工", width: 80, align: "center", sortable: true},
                {field: "updateDate", title: "更新时间", width: 130, align: "center", sortable: true, formatter: dateTimeFormatter},
                {field: "orderCount", title: "合作排期数", width: 80, align: "center", sortable: true},
                {field: "remark", title: "备注信息", width: 100, align: "center", formatter: remarkFormatter}
            ]],
			toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
			pageNumber: pageParam.pageNo,
			pageSize: pageParam.pageSize,
			pageList: Page.getPageList(),
			onSortColumn: function (orderBy, sortBy) {
				pageParam.pageNo = 1;
				pageParam.orderBy = orderBy;
				pageParam.sortBy = sortBy;
				query(pageParam);
			},
			onSelect: function() {
				selectedTableRow();
			},
			onUnselect: function() {
				selectedTableRow();
			},
			onSelectAll: function() {
				selectedTableRow();
			},
			onUnselectAll: function() {
				selectedTableRow();
			},
			onLoadSuccess: function() {
				toolBarBtnDisabledById([false, false, true, true, true, false, false], "buttonInfo");
			}
        }).datagrid("getPager").pagination({
			buttons: [
				{text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}}
			],
			onSelectPage: function(pageNumber, pageSize) {
				pageParam.pageNo = pageNumber;
				pageParam.pageSize = pageSize;
				query(pageParam);
			},
			onChangePageSize: function(pageSize) {
				pageParam.pageSize = pageSize;
			}
		});
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false, false, true, true, true, false, false], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false, false, false, false, false, false, false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false, false, true, true, false, false, false], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
		pageParam.condition = getFormJson($("#searchFormInfo"));
		pageParam.condition.type = 3;
        if (goHead && goHead)
            pageParam.pageNo = 1;
		ajaxGetFun("medium/querySelfMediumPage", pageParam, function(bizData) {
			$("#tableInfo").datagrid("loadData", bizData.rowList);
			$("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
		}, null, "获取我的抖音号列表");
    }

    //新增
    function addMedium() {
        openIframe(false, 500, 450, "medium-douyin-info.html", function() {}, function(index, layero) {
			var formEle = layero.find("iframe")[0].contentWindow.$("#formInfo");
			if (formEle.form("validate")) {
				ajaxPostFun("medium/saveMediumInfo", getFormJson(formEle), function() {
					layer.close(index);
					query(pageParam, true);
					showSuccessMsg("新增成功");
				}, null, "新建抖音号");
			}
		});
    }

    //修改
    function editMedium() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length !== 1) {
            return showWarnMsg("请选择一条条目后操作");
        }
        openIframe(false, 500, 450, "medium-douyin-info.html", function() {
			$("iframe")[0].contentWindow.$("#formInfo").form("load", selectRows[0]);
		}, function(index, layero) {
			var formEle = layero.find("iframe")[0].contentWindow.$("#formInfo");
			if (formEle.form("validate")) {
				ajaxPostFun("medium/updateMediumInfo", getFormJson(formEle), function() {
					layer.close(index);
					query(pageParam, true);
					showSuccessMsg("修改成功");
				}, null, "修改抖音号");
			}
		});
    }

    //删除
    function delMedium() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length === 0) {
            return showWarnMsg("请选择条目后操作");
        }
        layer.confirm("确认要删除选中的抖音号吗？", function() {
            ajaxPostFun("medium/deleteMediumInfoByIds", {ids: mergedRowCell(selectRows, "id")}, function(bizData) {
				query(pageParam, true);
				showSuccessMsg("已删除"+ bizData +"条数据");
			}, null, "删除抖音号");
        });
    }

    //转授
    function delegateMedium() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length === 0) {
            return showWarnMsg("请选择条目后操作");
        }
        ajaxGetFun("user/listUserByRoleCode", {roleCode: "ALL"}, function(bizData) {
            var html = '<div style="text-align: center; margin-top: 20px">';
            for (var i in bizData) {
                html += '<div style="height: 22px" onclick="$(this).children()[0].checked = true"><input type="radio" name="mediumUserId" value="'+ bizData[i].id +'" /><span>'+ bizData[i].name +'</span></div>';
            }
            html += '</div>';
            openHtml(false, 500, 300, html, null, function(index, layero) {
                var mediumUserId = getRadioValue("mediumUserId");
                if (mediumUserId == null) {
                    return showWarnMsg("请选择接收媒介");
                }
                ajaxPostFun("medium/delegateMediumInfo", {mediumIds: mergedRowCell(selectRows, "id"), mediumUserId: mediumUserId}, function() {
                    layer.close(index);
                    query(pageParam, true);
                    showSuccessMsg("转授成功");
                }, null, "转授抖音号");
            });
        }, null, "获取媒介列表");
    }
</script>
</body>
</html>